package base.variable;

import java.util.Arrays;

public class ArrayDemo {
    public static void main(String[] args) {
        int[] array;
        array = new int[5];
        for (int i = 0; i < array.length; i++) {
            array[i] = i + array.length;
        }
        System.out.println("array = " + Arrays.toString(array));
        double nums[] = { 1, 2, 3, 4, 5 };
        int i = 0;
        // collection iteration
        for (double num : nums) {
            System.out.println("nums[" + (i++) + "] = " + num);
        }
        // String array
        String[] opts = new String[] { "yes", "no" };
        System.out.println("opts = " + Arrays.toString(opts));
        // 2D array
        int[][] matrix = { { 1, 2 }, { 3, 4 } };
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                System.out.println("matirx[" + j + "][" + k + "] = " + matrix[j][k]);
            }
        }
    }
}
